import express from 'express';
import wyApi from '../../lib/wyapi'; // 维易接口API
import messageApi from '../../lib/messageapi'; // 消息通知相关API
import CONFIG from '../../../config/config.config'; // CONFIG
// import { checkPermission } from '../../utils/utils'; // 工具类

const router = express.Router();

router.get('/', async function (Request, Response, next) {
  let query = Request.query
  console.log(query)
  wyApi.getTkl({
    ...query,
    appkey: CONFIG.tblmAppKey,
    secret: CONFIG.tblmAppSecret,
  }).then(res => {
    console.log(res)
    if (res.msg) { // 唯易接口查询失败
      console.log(res.msg)
      // Response.status(300).send({ message: '很抱歉，该商品暂无优惠信息' });
      Response.json({
        ...res
      })
    } else {
      Response.json({
        ...res
      })
    }
  })
});

module.exports = router;